<!DOCTYPE html>
<html>

<head>
  <title>Register</title>

  {{template "include.html"}}
</head>

<body>

  {{template "header.html" .}}

  <div id="wrap">
    <div class="container">
      <div class="col-sm-1"></div>
      <div class="col-sm-4">
        <h2>Login</h2>
        <div class='well'>
          <form action="/login" method="post">

            <div class="form-group">
              <label>User</label>
              <input class='form-control' name="userid" />
            </div>
            <div class="form-group">
              <label>Password</label>
              <input class='form-control' name="password" type="password">
            </div>


            <!-- 				<table class="table">
					<tr>
						<td>Userid</td>
						<td><input class='form-control' name="userid"/></td>
					</tr>
					<tr>
						<td>Nick</td>
						<td><input class='form-control' name="password" type="password"></td>
					</tr>
				</table> -->

            <input class='btn btn-default' type="submit">
          </form>
        </div>
      </div>
      <div class="col-sm-1"></div>
      <div class="col-sm-4">
        <h2>Register</h2>
        <div class='well'>
          <form action="/register" method="post">
            <div class="form-group">
              <label>UserID</label>
              <input class='form-control' name="userid" value="geek" />
            </div>
            <div class="form-group">
              <label>Nick</label>
              <input class='form-control' name="nick">
            </div>
            <div class="form-group">
              <label>Password</label>
              <input class='form-control' name="pwd1" type="password" value="123" />
            </div>
            <div class="form-group">
              <label>Confirm</label>
              <input class='form-control' name="pwd2" type="password" value="123" />
            </div>
            <div class="form-group">
              <label>Email</label>
              <input class='form-control' name="mail" type="email" value="a@q.com" />
            </div>
            <input class='btn btn-default' type="submit">
            <!-- <table>
					<tr>
						<td>Userid*</td>
						<td><input class='form-control' name="userid" value="geek"  /></td>
					</tr>
					<tr>
						<td>Nick</td>
						<td><input class='form-control' name="nick"></td>
					</tr>
					<tr>
						<td>Password*</td>
						<td><input class='form-control' name="pwd1" type="password" value="123"  /></td>
					</tr>
					<tr>
						<td>Confirm*</td>
						<td><input class='form-control' name="pwd2" type="password" value="123"  /></td>
					</tr>
					<tr>
						<td>Email*</td>
						<td><input class='form-control' name="mail" type="email" value="a@q.com"  /></td>
					</tr>
				</table> -->

          </form>
        </div>
      </div>
    </div>
  </div>



  <script type="text/javascript" src="/static/js/jquery-3.2.1.min.js"></script>
  <script type="text/javascript" src="/static/js/utils.js"></script>
  <script type="text/javascript">
    $("form").bind("submit", function () {
      var tmp = ajaxSubmit(this, function () {
        var code = tmp.responseJSON.code;
        var ok = tmp.responseJSON.success;

        //	返回服务器信息
        // if ( code == 0 ) {
        if (ok == true) {
          alert("成功");
          location.href = '/setting'
        } else {
          alert(tmp.responseJSON.content)
        }
        return;

        // 使用code表示
        /*
          200		ok
          21x		login
            210	password
            211	block
          22x		register
            220	..
            221	..
        */
        switch (code) {
          case 0:
            // success
            alert("success");
            break;
          case 1:
            //	wrong password
            alert("wrong password");
            break;
          case 2:
            //	confrim faild
            alert("confrim faild");
            break;
        }

      });
      return false;
    })
  </script>

</body>

</html>